package com.tr.rentcar.model.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.tr.rentcar.model.GlobalParamHandler;
import com.tr.rentcar.model.bean.CarBrand;
import com.tr.rentcar.model.bean.CarStyle;
import com.tr.rentcar.model.bean.CarUse;
import com.tr.rentcar.model.jdbc.MySqlDb;
import com.tr.rentcar.model.jdbc.ResultHandler;

/**
 * 车辆用途数据处理
 * @author dell
 *
 */
public class CarUseDao implements ResultHandler<CarUse>{
	
	private MySqlDb db=MySqlDb.getInstance();

	@Override
	public CarUse doHander(Map<String, Object> row) {
		CarUse cu=new CarUse();
		cu.setCuId(Integer.parseInt(row.get("cu_id")+""));
		cu.setCuName(row.get("cu_name")+"");
		return cu;
	}
	
	//获取所有车辆用途
	public List<CarUse> getAll() throws SQLException{
		String sql="select * from car_use";
		return db.executeQuery(sql, this);
	}
	/*
	 通过名字找到该对象
	 */
	public CarUse findbyname(String cuname) throws SQLException{
		String sql="select * from car_use where cu_name=?";
		return db.queryUninResult(sql, new GlobalParamHandler(cuname),this);
	}

}
